package com.sun.controller.admin;


import com.alibaba.fastjson.JSON;
import com.sun.pojo.Checkin;
import com.sun.pojo.Employee;
import com.sun.service.CheckinService;
import com.sun.service.CheckoutService;
import com.sun.utils.DataGridViewResult;
import com.sun.utils.SystemConstant;
import com.sun.vo.CheckinVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;

@RestController
@RequestMapping("/admin/checkout")
public class CheckoutController {

    @Autowired
    private CheckoutService checkoutService;

    @RequestMapping("/addCheckout")
    public String addCheckin(Integer checkinid,Integer price, HttpSession session){
        Employee employee = (Employee) session.getAttribute(SystemConstant.LOGINUSER);
        HashMap<String, Object> map = new HashMap<String, Object>();
        if(checkoutService.addCheckout(checkinid,price,employee.getId())>0){
            map.put(SystemConstant.SUCCESS,true);
            map.put(SystemConstant.MESSAGE,"办理退房成功!");
        }else{
            map.put(SystemConstant.SUCCESS,true);
            map.put(SystemConstant.MESSAGE,"办理退房失败!");
        }
        return JSON.toJSONString(map);
    }
}
